<?php
/**
 * 入口
 *
 * @author		黑冰 <954650386@qq.com>
 */

error_reporting(E_ALL ^ E_NOTICE);

use \waf\Waf;
use \waf\AutoLoader;
use \waf\log\WLog;
use \waf\cmd\WCmd;
use \waf\server\WebSocketServer;

define("PUB_FILE",      __FILE__);
define("PUB_PATH",      dirname(PUB_FILE));
define("ROOT",          PUB_PATH . '/../..');
define("WAF_LIB_PATH",  ROOT . '/library');
define("APP_PATH",      PUB_PATH . '/../application');
define("APP_CONF_PATH", PUB_PATH . '/..');
define("APP_LIB_PATH",  PUB_PATH . '/../library');
define("APP_ENV",       isset($_SERVER['APP_ENV']) && $_SERVER['APP_ENV'] ? $_SERVER['APP_ENV'] : 'dev');

require_once(WAF_LIB_PATH . '/waf/AutoLoader.php');
AutoLoader::init();
AutoLoader::addClassMapDir(APP_LIB_PATH);

$arrCommonConf  = require_once(WAF_LIB_PATH . '/conf/common.php');
$arrAppConf     = require_once(APP_CONF_PATH . '/conf/common.php');
$arrEnvConf     = require_once(APP_CONF_PATH . '/conf/envcnf/'. APP_ENV .'/conf.php');
$arrConf        = Waf::array_merge_diff($arrCommonConf, $arrAppConf, $arrEnvConf);

Waf::initConfig($arrConf);
WLog::init();
WCmd::deal();

WLog::logSystem("server run ...", __FILE__, __LINE__, __FUNCTION__);
$objServer  = new WebSocketServer();
$objServer->start();
WLog::logSystem("server run done.", __FILE__, __LINE__, __FUNCTION__);
?>